<?php

// phpinfo();exit;
try{
	exit("dev");
	define('N_DEBUG', 0);						
	
	include 'core/Init.php';
	//n_p('-1-------------------完成初始化<br />');
//define('N_STYLE','simple');
//echo N_STYLE;
	$n = new Controller();
	n_api("debug")->set('dev');	//[0:dev,1:test,2:alpha,3:beat,4:public]
	//n_p('-2-------------------控制器初始化<br />');
	if(N_SCRIPT!='cli'){
		n_api("install")->check();
	}
	
	//出现某些情况，需要停止对外服务时，需要通过配置文件来决定系统是否临时关闭等。
	n_api("nconfig")->init();
	//n_p('-3-------------------安装初始化<br />');
	
	if(!in_array(N_EVENT,array("open","error","install")) && N_SCRIPT!='cli'){
		n_api("passport")->startSession();
		//n_p('-4-------------------用户初始化<br />');
		//n_api("manager")->reloadPrivate();
	}
	//echo N_EVENT;
	$n->run();
	//n_p('-5-------------------请求结束<br />');
	n_debug('succ_'.N_SCRIPT);
	
}catch(CException $c){
	//print_r($c);
	n_debug('core_'.N_SCRIPT);
	n_api("error")->fault($c);
	//n_go(n_url('error','http500',array('msg'=>$c->getMessage())));
	//n_fault($c);

}catch(PException $p){
	//print_r($p);
	n_debug('plugin_'.N_SCRIPT);
	n_api("error")->alert($p);
	//n_go(n_url('error','http500',array('msg'=>$p->getMessage())));
	
	//n_alert($p);

}catch(exception $e){
	//print_r($e);
	n_debug('ufo_'.N_SCRIPT);
	n_api("error")->ufo($e);
	//n_go(n_url('error','http404',array('msg'=>$e->getMessage())));
	
	//n_ufo($e);

}

